package l1j.opqlo.NewSystem;

import l1j.server.server.model.Instance.L1PcInstance;
import l1j.server.server.serverpackets.S_EffectLocation;
import l1j.server.server.serverpackets.S_SystemMessage;
import l1j.server.server.utils.Random;

public class play18La {

	 public static void playGame(L1PcInstance player, int type, int sum , int baotz) {       

         boolean isWin = false; // 判斷點數、大小的輸贏

         boolean isBaotz = false; // 判斷是否為豹子

         int locx = player.getX();

         int locy = player.getY();

         int a1 = Random.nextInt(6)+1; // 1~6點

         int a2 = Random.nextInt(6)+1;

         int a3 = Random.nextInt(6)+1;

         int point = a1 + a2 + a3;

         int gfx1 = 3203 + a1; // 骰子1的圖,3204為1點

         int gfx2 = 3203 + a2; // 骰子2的圖,3209為6點

         int gfx3 = 3203 + a3; // 骰子3的圖

         S_EffectLocation packet1 = new S_EffectLocation(locx+1, locy, gfx1);

         S_EffectLocation packet2 = new S_EffectLocation(locx, locy, gfx2);

         S_EffectLocation packet3 = new S_EffectLocation(locx-1, locy, gfx3);

         player.sendPackets(packet1);           

         player.sendPackets(packet2);           

         player.sendPackets(packet3);

//         player.broadcastPacket(packet1);
//
//         player.broadcastPacket(packet2);
//
//         player.broadcastPacket(packet3);

         if (type != 3){ // 不是賭豹子

               player.sendPackets(new S_SystemMessage("您擲出〈"+point+"〉點!!"));

         }           

         switch(type){

           case 1: // 小                   

                 if(point < 10){ // 1~9

                     isWin = true;

                 }               

                 break;

           case 2: // 大                   

                 if(point >= 10){ // 10~18                       

                     isWin = true;

             }               

                 break;

           case 3: // 豹子

                 if((a1 == a2) && (a2 == a3) && (a3 == baotz)){

                     isBaotz = true;

                 }

                 if(isBaotz){

                   player.sendPackets(new S_SystemMessage("恭喜您! 您擲出全是〈"+a1+"〉點的豹子!!"));

                     player.getInventory().storeItem(40308,20000000); // 賭豹子賠200倍

                     player.sendPackets(new S_SystemMessage("獲得賭金 2000 萬金幣!!"));                           

                 }

                 else{

                   player.sendPackets(new S_SystemMessage("真可惜! 不是您想要的豹子^^!!"));

                 }

                 break;

           case 4: // 壓點數

             if(point == sum){

               isWin = true;

             }

                 break;           

         }

         if(type !=3){ // 不是壓豹子

           if(isWin){

             if(type < 3){ // 賭大小

               player.getInventory().storeItem(40308,180000); // 賭大小賠1.8倍

               player.sendPackets(new S_SystemMessage("恭喜您壓中，獲得賭金 18 萬金幣!!"));

             }

             else if(type ==4){ // 壓點數

               player.getInventory().storeItem(40308,800000); // 賭點數賠8倍

               player.sendPackets(new S_SystemMessage("獲得賭金 80 萬金幣!!"));       

             }

           }

           else

               player.sendPackets(new S_SystemMessage("呵呵! 您的手氣不太好 ^^!!"));

         }           

     }
	
	
	
	
	
}
